<template xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
  <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
    <el-form-item prop="email" label="邮箱"  style="margin-left: -27px;width: 340px">
      <el-input v-model="ruleForm.email"></el-input>
    </el-form-item>
    <el-form-item label="密码" prop="pass" style="margin-left: -27px;width: 340px">
      <el-input type="password" v-model="ruleForm.pass" autocomplete="off"></el-input>
    </el-form-item>
    <a href="#" class="a"style="padding-top: 4px;">忘记密码？</a>
    <el-form-item style="margin-left: -30px">
      <!--        <el-button @click="rt()">点击注册</el-button>-->
      <el-button type="primary" @click="doLogin()" >立即登录</el-button>
      <el-button  @click="dialogFormVisible = true" style="margin-left:25px;">点击注册</el-button>

      <el-dialog title="欢迎注册" :visible.sync="dialogFormVisible"  width="40%" >
        <Register ></Register>
      </el-dialog>


    </el-form-item>
  </el-form>
</template>

<script>
    import Register from "./Register";

    export default {
        name: "LoginByEmail",
      components:{
        Register:Register
      },
      data() {

        var checkEmail= (rule, value, callback) => {
          if (value === '') {
            return callback(new Error('邮箱不能为空'));
          }
          else {
            callback();
          }
        };
        var validatePass = (rule, value, callback) => {
          if (value === '') {
            callback(new Error('请输入密码'));
          } else {
            callback();
          }

        };
        return {
          dialogFormVisible: false,
          ruleForm: {
            pass: '',
            email:'',
          },
          rules: {
            pass: [
              { validator: validatePass, trigger: 'blur' }
            ],
            email: [
              { validator: checkEmail, trigger: 'blur' },
              {  message: '请输入邮箱地址' },
              { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }
            ]
          }
        };
      }
    }
</script>

<style scoped>
  .a{
    text-decoration:none;
    font-size: 12px;
    position: absolute;
    top:105px;
    right: 10px;
    color: #333333;
  }
  .a:hover{color:red;}
</style>
